//
//  ifA.swift
//  swiftStudy
//
//  Created by unisedu on 16/4/1.
//  Copyright © 2016年 CaoFei. All rights reserved.
//

import UIKit
/**
 条件语句
 */
class ifA: NSObject {
    
    func show(){
        //使用元组
        let point1 = (3,4)
        switch point1
        {
        case(0,0):
            print("(0,0)")
        case(_,0):
            print("(\(point1.0),0)")
        case(0,_):
            print("(0,\(point1.1))")
        case(0...5,-1...10):
            print("(\(point1.0),\(point1.1))")
        default:
            print("error")
        }
        
        //value bindings
        //default如果条件全覆盖就可以不写
        let point2 = (1,2)
        switch point2
        {
        case (let x,0):
            print("\(x)")
        case(0,let y):
            print("\(y)")
        case let(x,y):
            print("(\(y),\(y))")
        }
        
        //where 
        
        let point3 = (1,-1)
        switch point3
        {
        case let(x,y) where x==y:
            print("x == y")
        case let(x,y) where x == -y:
            print("x == -y")
        case let(x,y):
            print("任意坐标点")
        }
    }
}
